package com.yunxin.customui.bean.table;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.StringJoiner;

/**
 * 动态下拉框向后台传 值 的类
 * 所有动态的下拉框的值  最终都将汇集到这个类中
 *
 * @author LGY
 * @date 2021/09/09
 */
@NoArgsConstructor
public class CustomFormValueBean {

    /**
     * 页面id
     */
    @Getter@Setter
    Integer pageId;

    /**
     * 电厂类型
     */
    @Getter@Setter
    Integer plantType;

    /**
     * 电厂id
     */
    @Getter@Setter
    Integer plantId;

    /**
     * 机组id
     */
    @Getter@Setter
    Integer genId;

    /**
     * agc id
     */
    @Getter@Setter
    Integer agcId;

    /**
     * 母线id
     */
    @Getter@Setter
    Integer busKVId;


    public CustomFormValueBean(CustomFormValueBean customFormValueBean) {
        this.pageId = customFormValueBean.pageId;
        this.plantType=customFormValueBean.plantType;
        this.plantId = customFormValueBean.plantId;
        this.genId = customFormValueBean.genId;
        this.agcId = customFormValueBean.agcId;
        this.busKVId = customFormValueBean.busKVId;
        this.beginTime = customFormValueBean.beginTime;
        this.endTime = customFormValueBean.endTime;
        this.dataId = customFormValueBean.dataId;
    }

    /**
     * 开始时间
     */
    @Getter
    String beginTime;
    public void setBeginTime(String beginTime){
        if (beginTime!=null){
            beginTime = beginTime.replace("%20"," ");
            if (beginTime.trim().length()==10){
                beginTime+=" 00:00:00";
            }
            this.beginTime = beginTime;
        }
    }
    /**
     * 结束时间
     */
    @Getter
    String endTime;
    public void setEndTime(String endTime){
        if (endTime != null){
            endTime = endTime.replace("%20"," ");
            if (endTime.trim().length()==10){
                endTime+=" 00:00:00";
            }
            this.endTime = endTime;
        }
    }

    /**
     * 数据点号
     */
    @Getter
    @Setter
    String dataId;






    public String toParamStr(){
        StringJoiner sj = new StringJoiner("&");
        if (plantType != null){
            sj.add("plantType="+plantType);
        }
        if (plantId!=null){
            sj.add("plantId="+plantId);
        }
        if (genId!=null){
            sj.add("genId="+genId);
        }
        if (agcId!=null){
            sj.add("agcId="+agcId);
        }
        if (busKVId!=null){
            sj.add("busKVId="+busKVId);
        }
        if (beginTime!=null){
            sj.add("beginTime="+beginTime);
        }
        if (endTime!=null){
            sj.add("endTime="+endTime);
        }
        if (dataId!=null){
            sj.add("dataId="+dataId);
        }

        return sj.toString();
    }


}
